package com.yuxi.mq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MQController {

    @Autowired
    private MQProduceService produceService;

    @Autowired
    private MQConsumerService consumerService;

    @RequestMapping("/send")
    public String send() {
        for (int i = 0; i <100 ; i++) {
            produceService.send("this is an activemq message"+i);
        }
        return "send";
    }

    @RequestMapping("/receive")
    public String receive() {

        String str = consumerService.receive();

        System.out.println("消费了。。。。。"+str);
        return str;
    }
}